﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using University.Workshop.Model;
using University.Workshop.DataAccess;
using University.Workshop.Business;
using System.Data;
using System.Windows.Forms;
using System.Collections.ObjectModel;

namespace University.Workshop.Tests
{
    /// <summary>
    ///This is a test class for RegistrationProductTest and is intended
    ///to contain all RegistrationProductTest Unit Tests
    ///</summary>
    [TestClass()]
    public class ProductRegisterTest
    {
        private TestContext testContextInstance;
        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion
        
       
        [TestMethod]
        public void RegisterProductTest()
        {
            Random random = new Random(DateTime.Now.Millisecond);
            string idProduct = "P"+random.Next(int.MaxValue);
            string group = "lacteos";
            string nameProduct = "leche pil";
            string cost = "6";
            string costSale = "7";
            string amount = "50";
            string dataSale = "viernes, 07 de mayo de 2011";
            RegistrationProduct.RegisterProduct(idProduct, group, nameProduct, cost,costSale,amount,dataSale);
           
             
        }
        /// <summary>
        ///A test for RegisterProduct
        ///</summary>
        [TestMethod()]
        public void RegisterProductBlankDataTest()
        {
            string idProduct = ""; // TODO: Initialize to an appropriate value
            string group = ""; // TODO: Initialize to an appropriate value
            string nameProduct = ""; // TODO: Initialize to an appropriate value
            string cost = ""; // TODO: Initialize to an appropriate value
            string costSale = ""; // TODO: Initialize to an appropriate value
            string amount = ""; // TODO: Initialize to an appropriate value
            string dateSale = ""; // TODO: Initialize to an appropriate value
            //int expected = 0; // TODO: Initialize to an appropriate value
            int actual;
            actual = RegistrationProduct.RegisterProduct(idProduct, group, nameProduct, cost, costSale, amount, dateSale);
            //Assert.AreEqual(expected, actual);
            //Assert.Inconclusive("Verify the correctness of this test method.");
        }

        /// <summary>
        ///A test for RegisterSale
        ///</summary>
        [TestMethod()]
        public void RegisterSaleTest()
        {
            string id = "123456"; // TODO: Initialize to an appropriate value
            string idRoom = "a123"; // TODO: Initialize to an appropriate value
            string costSaleProducts = "12"; // TODO: Initialize to an appropriate value
            string description = "Jugo,4,3-"; // TODO: Initialize to an appropriate value
            RegistrationProduct.RegisterSale(id, idRoom, costSaleProducts, description);
            //Assert.Inconclusive("A method that does not return a value cannot be verified.");
        }

        /// <summary>
        ///A test for UpDateByProduct
        ///</summary>
        [TestMethod()]
        public void UpDateByProductTest()
        {
            string productUpdate = "P10012345"; // TODO: Initialize to an appropriate value
            Product expected = null; // TODO: Initialize to an appropriate value
            Product actual;
            actual = RegistrationProduct.UpdateByproduct(productUpdate);
            Assert.AreEqual(expected, actual);
            //Assert.Inconclusive("Verify the correctness of this test method.");
        }


        /// <summary>
        ///Una prueba de SeekProduct
        ///</summary>
        [TestMethod()]
        public void SeekProductTest()
        {
            ProductRegister target = new ProductRegister(); // TODO: Inicializar en un valor adecuado
            target.Dispose();
            string product = "leche pil"; // TODO: Inicializar en un valor adecuado
            DataTable actual = new DataTable();
            actual = target.SeekProduct(product);
            Assert.AreEqual(true,actual.Rows.Count>0);
        }

        /// <summary>
        ///A test for GetAllProducts
        ///</summary>
        [TestMethod()]
        public void GetAllProductsTest()
        {
            ProductRegister target = new ProductRegister(); // TODO: Initialize to an appropriate value
            DataGridView products = new DataGridView(); // TODO: Initialize to an appropriate value
            DataGridViewTextBoxColumn IdProduct = new DataGridViewTextBoxColumn();
            DataGridViewTextBoxColumn Group = new DataGridViewTextBoxColumn();
            DataGridViewTextBoxColumn NameProduct = new DataGridViewTextBoxColumn();
            DataGridViewTextBoxColumn CostBuy = new DataGridViewTextBoxColumn();
            DataGridViewTextBoxColumn CostSale = new DataGridViewTextBoxColumn();
            DataGridViewTextBoxColumn Amount = new DataGridViewTextBoxColumn();
            DataGridViewTextBoxColumn Date = new DataGridViewTextBoxColumn();
            IdProduct.Name = "IdProduct";
            Group.Name = "Group";
            NameProduct.Name = "NameProduct";
            CostBuy.Name = "CostBuy";
            CostSale.Name = "CostSale";
            Amount.Name = "Amount";
            Date.Name = "Date";
            products.Columns.AddRange(new DataGridViewColumn[] { IdProduct, Group, NameProduct, CostBuy, CostSale, Amount, Date });
            target.GetAllProducts(products);
           
        }

        /// <summary>
        ///A test for SearchProductByGroup
        ///</summary>
        [TestMethod()]
        public void SearchProductByGroupTest()
        {
            ProductRegister target = new ProductRegister(); // TODO: Initialize to an appropriate value
            string group = "lacteos"; // TODO: Initialize to an appropriate value
            DataTable actual;
            actual = target.SearchProductByGroup(group);
            Assert.IsTrue(actual.Rows.Count > 0);
        }

        /// <summary>
        ///A test for GetAllSaleClient
        ///</summary>
        [TestMethod()]
        public void GetAllSaleClientTest()
        {
            ProductRegister target = new ProductRegister(); // TODO: Initialize to an appropriate value
            string idClient = "12345"; // TODO: Initialize to an appropriate value
            Collection<Sale> actual;
            actual = target.GetAllSaleClient(idClient);
        }
    }
}
